// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 

package net.minecraft;

import net.minecraft.util.*;
import java.io.*;
import java.util.ArrayList;

// Referenced classes of package net.minecraft:
//            LauncherFrame

public class MinecraftLauncher
{

    //private static final long MIN_HEAP = 511L;
    //private static final long RECOMMENDED_HEAP = 1024L;
    private static boolean debugMode = false;

    public MinecraftLauncher()
    {
    }

    public static void main(String args[])
        throws Exception
    {
        if(args.length > 0 && args[0].contains("debug"))
        {
            debugMode = true;
        }
        long l = Runtime.getRuntime().maxMemory() / 1024L / 1024L;
        if(l > 511L)
        {
            LauncherFrame.main(args);
        } else
        {
            ArrayList<String> arraylist = new ArrayList<String>();
            String s = (net.minecraft.MinecraftLauncher.class).getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
            arraylist.add("javaw");
            arraylist.add("-Xms512m");
            arraylist.add("-Xmx1024m");
            arraylist.add("-Dsun.java2d.noddraw=true");
            arraylist.add("-Dsun.java2d.d3d=false");
            arraylist.add("-Dsun.java2d.opengl=false");
            arraylist.add("-Dsun.java2d.pmoffscreen=false");
            arraylist.add("-classpath");
            arraylist.add(s);
            arraylist.add("net.minecraft.LauncherFrame");
            if(!debugMode)
            {
                try
                {
                    ProcessBuilder processbuilder = new ProcessBuilder(arraylist);
                    Process process1 = processbuilder.start();
                    if(process1 == null)
                    {
                        throw new Exception("!");
                    }
                    System.exit(0);
                }
                catch(IOException ioexception) { }
            }
            try
            {
                arraylist.set(0, "java");
                ProcessBuilder processbuilder1 = new ProcessBuilder(arraylist);
                final Process process = processbuilder1.start();
                if(process == null)
                {
                    throw new IOException("!");
                }
                if(debugMode)
                {
                    final OutputConsole console = new OutputConsole();
                    final BufferedReader reader1 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                    final BufferedReader reader2 = new BufferedReader(new InputStreamReader(process.getInputStream()));
                    Thread thread = new Thread() {

                        BufferedReader reader;

                        public void run()
                        {
                            boolean flag = false;
                            boolean flag1 = true;
                            String s1 = "";
                            console.acquire();
                            do
                            {
                                if(flag || s1 == null)
                                {
                                    break;
                                }
                                int i = 0x80000000;
                                try
                                {
                                    i = process.exitValue();
                                }
                                catch(IllegalThreadStateException illegalthreadstateexception)
                                {
                                    try
                                    {
                                        s1 = reader.readLine();
                                        System.err.println(s1);
                                        console.appendText((new StringBuilder()).append("\nError: ").append(s1).toString());
                                    }
                                    catch(IOException ioexception2)
                                    {
                                        s1 = null;
                                    }
                                }
                                if(i != 0x80000000)
                                {
                                    flag = true;
                                    if(i != 0)
                                    {
                                        flag1 = false;
                                    }
                                }
                            } while(true);
                            if(flag1)
                            {
                                console.release();
                            }
                        }

            
            {
                reader = reader1;
            }
                    }
;
                    Thread thread1 = new Thread() {

                        BufferedReader reader;

                        public void run()
                        {
                            boolean flag = false;
                            boolean flag1 = true;
                            String s1 = "";
                            console.acquire();
                            do
                            {
                                if(flag || s1 == null)
                                {
                                    break;
                                }
                                int i = 0x80000000;
                                try
                                {
                                    i = process.exitValue();
                                }
                                catch(IllegalThreadStateException illegalthreadstateexception)
                                {
                                    try
                                    {
                                        s1 = reader.readLine();
                                        System.out.println(s1);
                                        console.appendText((new StringBuilder()).append("\nOutput: ").append(s1).toString());
                                    }
                                    catch(IOException ioexception2)
                                    {
                                        s1 = null;
                                    }
                                }
                                if(i != 0x80000000)
                                {
                                    flag = true;
                                    if(i != 0)
                                    {
                                        flag1 = false;
                                    }
                                }
                            } while(true);
                            if(flag1)
                            {
                                console.release();
                            }
                        }

            
            {
                reader = reader2;
            }
                    }
;
                    thread.start();
                    thread1.start();
                }
                if(!debugMode)
                {
                    System.exit(0);
                }
            }
            catch(IOException ioexception1)
            {
                System.out.println("Java couldn't figure out a way to get more memory.\nIf the game crashes, run to the hills!");
                LauncherFrame.main(args);
            }
        }
    }

}
